<template>
    <div>
<van-tabbar active-color="#F63515" inactive-color="#000" fixed route>
        <van-tabbar-item replace to='/' icon="wap-home-o">首页</van-tabbar-item>
        <van-tabbar-item replace to='/category' icon="point-gift-o">分类</van-tabbar-item>
        <van-tabbar-item  v-if="$store.getters.getBadgeCount > 0"  :badge="$store.getters.getBadgeCount" replace to='/shopcar' icon="shopping-cart-o">购物车</van-tabbar-item>
        <van-tabbar-item v-else replace to='/shopcar' icon="shopping-cart-o">购物车</van-tabbar-item>
        <van-tabbar-item replace to='/me' icon="user-o">我的</van-tabbar-item>
</van-tabbar>
    </div>
</template>

<script>
    export default {
       props: {
    active: {
      type: Number,
      default: 0
    },
  },
  data() {
    return {
      select: 0,
    }
  },
  created() {
    this.select = this.active
  },
  methods: {
    changeTabbar(index) {
      // console.log('index:', index);
      if (index === 0) {
        this.$router.push("/").catch(() => {});
      } else if (index === 1) {
        this.$router.push("/category").catch(() => {});
      } else if (index === 2) {
        this.$router.push("/shopcar").catch(() => {});
      } else if (index === 3) {
        this.$router.push("/me").catch(() => {});
      }
    },
  },
    }
</script>

<style lang="scss" scoped>

</style>